<html>
<head><meta charset="utf-8"><title>Add StatementKind::Call to MIR compiler-team#348 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html">Add StatementKind::Call to MIR compiler-team#348</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207677151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207677151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207677151">(Aug 21 2020 at 19:52)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/compiler-team/issues/348">Add StatementKind::Call to MIR #348</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="207678570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207678570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207678570">(Aug 21 2020 at 20:06)</a>:</h4>
<p>this I think needs a benefit vs complexity evaluation. Rust seems like a language that's excessively unlikely to not have cleanups in any given function.</p>



<a name="207678641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207678641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207678641">(Aug 21 2020 at 20:07)</a>:</h4>
<p>(this is also super easy to check, just count how many of our current terminators end up without a cleanup edge.</p>



<a name="207681203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207681203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207681203">(Aug 21 2020 at 20:31)</a>:</h4>
<blockquote>
<p>function calls that do not under any circumstance panic or unwind</p>
</blockquote>
<p>Would this include all functions that are compiled under <code>panic=abort</code>?</p>



<a name="207684849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207684849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207684849">(Aug 21 2020 at 21:04)</a>:</h4>
<p>yeah, but panic=abort is a fairly special case scenario by itself. That said, I wouldn’t oppose this change if we also start requiring that the calls at a terminator position have a unwind edge.</p>



<a name="207684934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207684934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207684934">(Aug 21 2020 at 21:05)</a>:</h4>
<p>(i.e. make <a href="https://github.com/rust-lang/rust/blob/de521cbb303c08febd9fa3755caccd4f3e491ea3/src/librustc_middle/mir/terminator/mod.rs#L118">https://github.com/rust-lang/rust/blob/de521cbb303c08febd9fa3755caccd4f3e491ea3/src/librustc_middle/mir/terminator/mod.rs#L118</a> a <code>BasicBlock</code> instead of <code>Option&lt;BasicBlock&gt;</code>)</p>



<a name="207710072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207710072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207710072">(Aug 22 2020 at 06:12)</a>:</h4>
<p>This breaks the assumption that <code>Statement</code>s have no side effects (in particular that they do not diverge). <code>LlvmAsm</code> works around this with some hacks (<a href="https://github.com/rust-lang/rust/blob/e3a4b16bd0eb633b3088c4c8a07f6f19d0be7ae6/src/librustc_mir/transform/simplify_try.rs#L600">1</a> <a href="https://github.com/rust-lang/rust/blob/e3a4b16bd0eb633b3088c4c8a07f6f19d0be7ae6/src/librustc_mir/transform/unreachable_prop.rs#L27">2</a>).</p>



<a name="207710088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207710088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207710088">(Aug 22 2020 at 06:13)</a>:</h4>
<p>Ideally we will want to remove these hacks once <code>llvm_asm!</code> is fully deprecated and removed (replaced by <code>asm!</code> which is a terminator in MIR).</p>



<a name="207718619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207718619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207718619">(Aug 22 2020 at 10:44)</a>:</h4>
<p>Right, the point of these <code>StatementKind::Call</code> is to not have diverging calls at all. Things like <code>transmute</code>, <code>memcpy</code>, <code>size_of</code>, ...</p>



<a name="207718846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207718846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207718846">(Aug 22 2020 at 10:50)</a>:</h4>
<p>Maybe call it <code>CallIntrinsic</code> then and give it a <code>(DefId, SubstsRef)</code> as function to call instead of <code>Operand</code>, indirect calls can't be represented.</p>



<a name="207724006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207724006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207724006">(Aug 22 2020 at 13:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348/near/207718619">said</a>:</p>
<blockquote>
<p>Right, the point of these <code>StatementKind::Call</code> is to not have diverging calls at all. Things like <code>transmute</code>, <code>memcpy</code>, <code>size_of</code>, ...</p>
</blockquote>
<p>I guess that makes sense, I recall us wanting to special case some of these for quite some time.</p>



<a name="207724095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207724095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207724095">(Aug 22 2020 at 13:16)</a>:</h4>
<p>but that also requires that we have in MIR something like the <code>readnone</code> attribute in LLVM which we don’t currently. We could special case some specific symbols but something named <code>Call</code> seems too generic for what it would do without such an attribute (and <code>CallIntrinsic</code> too limiting given that we might be able to eventually add such a attribute or whatever)</p>



<a name="207730286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207730286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207730286">(Aug 22 2020 at 16:03)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> this sounds very relevant to the <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278/near/207208336">options we discussed/considered before moving injected coverage "calls" from the <code>Call</code> terminator to the new <code>StatementKind::Coverage</code></a>, before landing PR <a href="https://github.com/rust-lang/rust/issues/75563">#75563</a>.</p>



<a name="207732735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207732735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207732735">(Aug 22 2020 at 16:58)</a>:</h4>
<p>to me <code>StatementKind::Coverage</code> seems like the most elegant solution, especially when thinking who will want to care about that. Nesting these constructs or hiding them behind a <code>Call</code> makes them more difficult inspect/handle.</p>



<a name="207742088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207742088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207742088">(Aug 22 2020 at 21:03)</a>:</h4>
<p>Side note: we managed to special case <code>size_of</code>, <code>align_of</code> and any other functions with no arguments by making them constants</p>



<a name="207749262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/207749262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#207749262">(Aug 23 2020 at 00:56)</a>:</h4>
<p>Would it be significantly difficult to start of super conservatively with something like <code>CallIntrinsic</code> that handles just things like <code>transmute</code>, <code>memcpy</code>, and then when it becomes more clear what a more general solution would be to expand to encompass that as well?</p>



<a name="208032114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208032114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208032114">(Aug 25 2020 at 22:27)</a>:</h4>
<p>I like starting out with the conservative thing, but we should at least have a plan for future extensions. Side note: <code>memcpy</code> is actually <a href="https://doc.rust-lang.org/std/intrinsics/fn.copy_nonoverlapping.html">copy_nonoverlapping</a></p>



<a name="208045494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208045494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208045494">(Aug 26 2020 at 01:56)</a>:</h4>
<p>This is fair enough, I guess the main intent of this is to make it easier to perform optimizations on the code, because I can't see it enabling any functionality that was not existing prior. As such, I think it would be idea to also follow nagisa's suggestion to</p>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348/near/207684934">said</a>:</p>
<blockquote>
<p>(i.e. make <a href="https://github.com/rust-lang/rust/blob/de521cbb303c08febd9fa3755caccd4f3e491ea3/src/librustc_middle/mir/terminator/mod.rs#L118">https://github.com/rust-lang/rust/blob/de521cbb303c08febd9fa3755caccd4f3e491ea3/src/librustc_middle/mir/terminator/mod.rs#L118</a> a <code>BasicBlock</code> instead of <code>Option&lt;BasicBlock&gt;</code>)</p>
</blockquote>
<p>I'm not familiar at all with <code>Coverage</code>, but from my POV it appears that the point of that would be drastically different than promoting some function calls to <code>StatementKinds</code>. I think under the <code>panic=abort</code> circumstance, would it make sense to include every function? I think it only makes sense if the behaviour right now is to remove unwind edges when compiled with that option, otherwise I worry about (mis-)optimizations causing differing behaviour that is hard to find.</p>



<a name="208342944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208342944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208342944">(Aug 28 2020 at 13:34)</a>:</h4>
<p>I'm not close enough to the work on compiler optimizations, I guess, to make a call on this. From the POV of borrow checker and type-checker, it seems to just make everything a bit more complicated.</p>



<a name="208342967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208342967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208342967">(Aug 28 2020 at 13:34)</a>:</h4>
<p>Can someone elaborate a bit on the <em>benefits</em>?</p>



<a name="208343007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208343007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208343007">(Aug 28 2020 at 13:35)</a>:</h4>
<p>Is it that basic-block-local optimizations become more effective?</p>



<a name="208343028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208343028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208343028">(Aug 28 2020 at 13:35)</a>:</h4>
<p>I could imagine memory use improvements as well</p>



<a name="208360075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360075">(Aug 28 2020 at 15:48)</a>:</h4>
<p>It would make several optimizations more effective as they must currently treat function calls as these opaque side-effecting things</p>



<a name="208360240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360240">(Aug 28 2020 at 15:49)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I don't understand why a function call in a statement is any less opaque</p>



<a name="208360311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360311">(Aug 28 2020 at 15:50)</a>:</h4>
<p>if it's a matter of "we've analyzed it and we've identified it doesn't have side effects", couldn't we set a flag on the terminator too?</p>



<a name="208360314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360314">(Aug 28 2020 at 15:50)</a>:</h4>
<p>these are just function calls that cannot unwind</p>



<a name="208360359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360359">(Aug 28 2020 at 15:50)</a>:</h4>
<p>right but we already have only one outgoing edge from such functions</p>



<a name="208360381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360381">(Aug 28 2020 at 15:50)</a>:</h4>
<p>sure, that would work, too, and is basically what <span class="user-mention" data-user-id="123586">@nagisa</span> suggested (make the unwind path an <code>Option</code>)</p>



<a name="208360517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360517">(Aug 28 2020 at 15:51)</a>:</h4>
<p>so... we'd change the optimizations to handle function calls without an unwind edge the way we'd treat these hypothetical function call statements</p>



<a name="208360664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208360664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208360664">(Aug 28 2020 at 15:52)</a>:</h4>
<p>that's an alternative I guess. it won't reduce the number of basic blocks, but I gotta look at the motivating examples for this MCP to see if that would work, too. Doing that now</p>



<a name="208366642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208366642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208366642">(Aug 28 2020 at 16:42)</a>:</h4>
<p>If we're doing anything I’m a strong proponent for trying statements for specific things we want to handle specially and only when that becomes unwieldy to look into generalizing.</p>



<a name="208435088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208435088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208435088">(Aug 29 2020 at 13:54)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I thought we already had functions with an optional unwind edge</p>



<a name="208435093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208435093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208435093">(Aug 29 2020 at 13:54)</a>:</h4>
<p>am I misremembering?</p>



<a name="208435113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208435113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208435113">(Aug 29 2020 at 13:55)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> I'm not sure I understand that comment, I can't tell if it is in favor of the MCP as proposed or some alternative -- e.g., maybe having a specialized statement for specific builtin functions?</p>



<a name="208437404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208437404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208437404">(Aug 29 2020 at 14:48)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think that was in reference to the <code>Coverage</code> statement we recently added for the LLVM code coverage feature. Before adding that, we were using a regular LLVM intrinsic so we generated function calls to it which had unwind edges. That worked but it made the instrumentation pass pretty complex because we basically doubled (or more) the number of function calls in a given body. </p>
<p>Recently, we changed this and added a <code>Coverage</code> statement which just lowers to the intrinsic and cannot unwind. I actually suggested adding <code>StatementKind::Call</code> at that time instead of the more specific <code>Coverage</code> statement but now I'm glad we didn't do that. <code>Coverage</code> has simple semantics and 90% of the compiler doesn't need to care about it at all so it's very easy to see that it's handled correctly. Only <code>cg_llvm</code> needs to do anything with it. </p>
<p>So I totally agree with <span class="user-mention" data-user-id="123586">@nagisa</span> in regards to "trying statements for specific things we want to handle specially and only when that becomes unwieldy to look into generalizing"</p>



<a name="208437413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208437413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208437413">(Aug 29 2020 at 14:49)</a>:</h4>
<p>Yeah, I’m advocating for an alternative much like <code>Coverage</code> statement we have right now.</p>



<a name="208437696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208437696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208437696">(Aug 29 2020 at 14:55)</a>:</h4>
<p>That said, I could see how making function calls that cannot unwind statements instead of terminators could improve performance. I think we have some MIR passes which are super linear in the number of basic blocks (I could totally be wrong about that)  so reducing the number of blocks would be a win. I'm not sure this makes writing MIR optimizations easier as call statements are just as side effect-y as call terminators are. </p>
<p>So, <em>if</em> this improves performance it <em>may</em> be worth the additional complexity but I don't see how we could know that without doing the work and then testing it.</p>



<a name="208446828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208446828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208446828">(Aug 29 2020 at 18:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348/near/207710072">said</a>:</p>
<blockquote>
<p>This breaks the assumption that <code>Statement</code>s have no side effects (in particular that they do not diverge). <code>LlvmAsm</code> works around this with some hacks (<a href="https://github.com/rust-lang/rust/blob/e3a4b16bd0eb633b3088c4c8a07f6f19d0be7ae6/src/librustc_mir/transform/simplify_try.rs#L600">1</a> <a href="https://github.com/rust-lang/rust/blob/e3a4b16bd0eb633b3088c4c8a07f6f19d0be7ae6/src/librustc_mir/transform/unreachable_prop.rs#L27">2</a>).</p>
</blockquote>
<p>there are statements with side-effects -- <code>*x = ...</code>, for example. but indeed diverging statements would be something new which seems problematic, also for optimizations.</p>



<a name="208446933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208446933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208446933">(Aug 29 2020 at 18:19)</a>:</h4>
<p>for example, currently if we have <code>stmt1; stmt2; stmt3</code> and the last one causes UB, we can just replace the entire block by "unreachable". once <code>stmt2</code> might diverge, that is no longer correct.</p>



<a name="208446993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208446993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208446993">(Aug 29 2020 at 18:20)</a>:</h4>
<p>in fact I think the term "basic block" should be changed then, as it no longer matches what the rest of the world calls a "basic block"</p>



<a name="208459278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208459278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208459278">(Aug 29 2020 at 23:29)</a>:</h4>
<p>Ah but for the proposed <code>StatementKind::Call</code>, it would only permit convergent functions. Whether that should be a small subset of intrinsics that are known to converge as a conservative approach or to open up much more to all functions that converge and restricting <code>TerminatorKind::Call</code> I think is where the split among opinion currently is. I think it would be more feasible to start with a limited subset and expand later if it's promising, altho I think earlier I thought it might be cleaner to refactor <code>TerminatorKind::Call</code>, that would be  significantly larger effort which while related is not necessarily tied to this change</p>



<a name="208471834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208471834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208471834">(Aug 30 2020 at 06:46)</a>:</h4>
<blockquote>
<p>Ah but for the proposed StatementKind::Call, it would only permit convergent functions. </p>
</blockquote>
<p>That would help a lot. This was said somewhere in the beginning of this thread, but later people kept just talking about doing this for all nounwind functions, so I got worried.</p>



<a name="208471844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208471844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208471844">(Aug 30 2020 at 06:47)</a>:</h4>
<p>it's still a bit tricky though -- we'd have to say something like "it is UB for a <code>StatementKind::Call</code> to never return". this is UB Miri cannot test for, it is non-decidable UB (see halting problem). That's not great.</p>



<a name="208471888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208471888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208471888">(Aug 30 2020 at 06:48)</a>:</h4>
<p>also the exact clause is something like "the function must always return in every execution", i.e., if the function depends on external input (say, reads from a file or so) then no matter what happens it must return.</p>



<a name="208471901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208471901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208471901">(Aug 30 2020 at 06:49)</a>:</h4>
<p>so considering all that I am definitely in favor of doing this only for intrinsics; AFAIK all our intrinsics always return (except maybe the ones around unwinding?). then I'd call it <code>StatementKind::Intrinsic</code>. whether or not we also use that for nullary intrinsics (or keep treating them as consts), I am not sure what is better.</p>



<a name="208472830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208472830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208472830">(Aug 30 2020 at 07:20)</a>:</h4>
<p>I think the volatile group of intrinsics should also be forbidden for StatementKind::Call.</p>



<a name="208473296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208473296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208473296">(Aug 30 2020 at 07:34)</a>:</h4>
<p>These are all the intrinsics which have "volatile" in the function name, or are there others?</p>



<a name="208473900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208473900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208473900">(Aug 30 2020 at 07:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348/near/208472830">said</a>:</p>
<blockquote>
<p>I think the volatile group of intrinsics should also be forbidden for StatementKind::Call.</p>
</blockquote>
<p>hm... that is probably a reasonably conservative choice, so we do not have to answer the question if UB is allowed to go backwards in time across volaltile accesses</p>



<a name="208473902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208473902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208473902">(Aug 30 2020 at 07:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="326189">jknodt</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348/near/208473296">said</a>:</p>
<blockquote>
<p>These are all the intrinsics which have "volatile" in the function name, or are there others?</p>
</blockquote>
<p>that should be the ones yes</p>



<a name="208473908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208473908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208473908">(Aug 30 2020 at 07:57)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span>  I dont think compiler fences are UB barriers? (If they are, then we'd also have to exclude those and atomic fences... and atomic accesses...)</p>



<a name="208475852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208475852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208475852">(Aug 30 2020 at 09:02)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I was thinking about the fact that volatile memory accesses may have side-effects, which could for example reasonably include pausing the process forever allowing another process to read the value stored by the volatile store. I just read the LLVM lang ref and it says "The compiler may assume execution will continue after a volatile operation, so operations which modify memory or may have undefined behavior can be hoisted past a volatile operation." (<a href="https://llvm.org/docs/LangRef.html#volatile-memory-accesses">https://llvm.org/docs/LangRef.html#volatile-memory-accesses</a>)., so it would indeed be UB for a volatile memory access to be followed by "unreachable".</p>



<a name="208477268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208477268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208477268">(Aug 30 2020 at 09:48)</a>:</h4>
<p>ah, interesting... so given we could likely make them statements as well</p>



<a name="208477279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208477279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208477279">(Aug 30 2020 at 09:49)</a>:</h4>
<p>I am thinking of volatile accesses as "syscalls the compiler knows something about (so it can optimize more around them)"; I just didn't have "the syscall always returns" on my list of "things the compiler knows"</p>



<a name="208477528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208477528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208477528">(Aug 30 2020 at 09:57)</a>:</h4>
<p>Neither did I.</p>



<a name="208890649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208890649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208890649">(Sep 02 2020 at 21:33)</a>:</h4>
<p>I see, if this is not a general call mechanism, but is tailored to specific intrinsics, then I think I agree with <span class="user-mention" data-user-id="123586">@nagisa</span> and <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> that custom statements is likely better</p>



<a name="208904510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/208904510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#208904510">(Sep 03 2020 at 00:01)</a>:</h4>
<p>Should I update the MCP with the relevant discussion then?</p>



<a name="209317183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209317183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209317183">(Sep 07 2020 at 17:50)</a>:</h4>
<p>I've updated the <a href="https://github.com/rust-lang/compiler-team/issues/348">main issue</a> with relevant discussion, not sure if I correctly interpreted all the comments here.</p>



<a name="209353338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209353338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209353338">(Sep 08 2020 at 07:28)</a>:</h4>
<p>I think <span class="user-mention" data-user-id="123586">@nagisa</span> suggested a special <code>Rvalue::Transmute</code> instead of a <code>StatementKind::Intrinsic</code> and potentially other variants for intrinsics or other operations as we need them</p>



<a name="209353579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209353579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209353579">(Sep 08 2020 at 07:31)</a>:</h4>
<p>I think the original motivator for this MCP was <code>copy_nonoverlapping</code>, which could be created via <code>StatementKind::CopyNonoverlapping(Place, Place)</code></p>



<a name="209366038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209366038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209366038">(Sep 08 2020 at 09:55)</a>:</h4>
<p>Oh. we also need a byte count I guess. so <code>StatementKind::CopyNonoverlapping { source: Place, dest: Place, num_bytes: Size }</code></p>



<a name="209366066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209366066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209366066">(Sep 08 2020 at 09:55)</a>:</h4>
<p>we can always change it to have a type and an number of elements field if that becomes a use case</p>



<a name="209482337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209482337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209482337">(Sep 09 2020 at 08:08)</a>:</h4>
<p>Ah alright, that's even more specific than I thought but sounds good</p>



<a name="209537312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/209537312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#209537312">(Sep 09 2020 at 16:50)</a>:</h4>
<p>alright I've updated the MCP again</p>



<a name="210561608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/210561608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#210561608">(Sep 18 2020 at 18:57)</a>:</h4>
<p>note that since the MCP issue title changed, the bot posted my "second" in <a class="stream-topic" data-stream-id="233931" href="/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20StatementKind.3A.3AIntrinsic.20to.20MIR.20compiler-team.23348">#t-compiler/major changes &gt; Add StatementKind::Intrinsic to MIR compiler-team#348</a></p>



<a name="210561688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/210561688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#210561688">(Sep 18 2020 at 18:58)</a>:</h4>
<p>also <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> and <span class="user-mention" data-user-id="123586">@nagisa</span> I took the liberty of seconding this, but I'd like y'all to approve since I'm not closely monitoring this sort of work <em>really</em> :)</p>



<a name="210585681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Add%20StatementKind%3A%3ACall%20to%20MIR%20compiler-team%23348/near/210585681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Add.20StatementKind.3A.3ACall.20to.20MIR.20compiler-team.23348.html#210585681">(Sep 18 2020 at 23:34)</a>:</h4>
<p>thirded.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>